package com.kgcx.common.rabbitmq.producer;

import com.alibaba.fastjson.JSONObject;
import com.kgcx.common.rabbitmq.bean.MqFail;
import com.kgcx.common.rabbitmq.consts.ExchangeConst;
import com.kgcx.common.rabbitmq.consts.RoutingKeyConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 吴刚林
 * @date 2017/11/20
 */
@Slf4j
@Component
public class MqFailProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    public void mqFail(MqFail mqFail) {
        //log.info(String.format("新增车辆记录新增成功的MQ消息，车辆id[%s]。", auto.getKid()));
        rabbitTemplate.convertAndSend(ExchangeConst.MQ_FAIL, RoutingKeyConst.MQ_FAIL,
                JSONObject.toJSONString(mqFail));
    }


}
